home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / tibtaz.zip / TIBTAZ.ASM next >
Assembly Source File  |  1993-04-01  |  3KB  |  95 lines

  1.         PAGE    62,130
  2.         TITLE   TIBTAZ.ASM - Trap (Int3) Branch To Absolute Zero
  3. ;******************************************************************************
  4. ;Written by Bruce T. Findlay, March 1992.  Contributed to the Public Domain.
  5. ;
  6. ;This program changes the vector for Interrupt 0 ("divide by zero"), such that
  7. ; the prior handler gets control for genuine quotient-cannot-be-represented
  8. ; problems, but that an attempt to directly execute the vector will bring up
  9. ; the debugger of choice (read: Periscope).  
  10. ;It is a very small TSR; executables that provide their own divide-by-zero 
  11. ; handler will defeat TIBTAZ.  Assembly programmers making use of jump tables
  12. ; filled in at run time will get the greatest benefit.
  13. ;
  14.  
  15.         Public  EnvSeg, TIBTAZ, cnfe, PRHEX, PHG, PGMNAME, CRLF
  16.  
  17.         CSEG    SEGMENT PARA PUBLIC 'CODE'
  18.         ASSUME  CS:CSEG, DS:CSEG, ES:CSEG
  19.  
  20.         ORG     02Ch
  21. EnvSeg  dw      ?
  22.  
  23.         ORG     0100H                   ;a not-so traditional COM program
  24. TIBTAZ: MOV     AL,0H                   ;read old vector
  25.         MOV     AH,035H
  26.         INT     021H
  27.  
  28.         mov     dx, es                  ;save just-read seg
  29.         push    ds
  30.         pop     es                      ;make Assume true again
  31.         mov     di, 0CCh                ;address of new "handler" (in our PSP)
  32.         cld
  33.         mov     al, 0EAh                ;JMP rel16 op code
  34.         stosb
  35.         mov     ax, bx                  ;offset of old handler
  36.         stosw
  37.         mov     ax, dx                  ;and segment
  38.         stosw
  39.  
  40.         mov     DX, 0CCh                ;offset of new version (DS is the seg)
  41.         MOV     AL,0H
  42.         MOV     AH,025H
  43.         INT     021H                    ;assign it
  44.  
  45.         ;release environment (!)
  46.         mov     ax, [EnvSeg]            ;segment of environment
  47.         mov     es, ax                  ;where DOS expects it
  48.         mov     ah, 049h                ;free mem func
  49.         int     021h
  50.         jc      cnfe                    ;br as we could not free environment
  51.         xor     ax, ax
  52.         mov     [EnvSeg], ax            ;mark w/zero so no one else reads it
  53. cnfe:
  54.         
  55.         ;now name program & PSP on the way out
  56.         LEA     DX,PGMNAME
  57.         MOV     AH,9
  58.         INT     021H
  59.         MOV     BX,CS                   ;ugly, but it works.
  60.         MOV     CL,4
  61.         MOV     AL,BH
  62.         SHR     AL,CL
  63.         CALL    PRHEX
  64.         MOV     AL,BH
  65.         CALL    PRHEX
  66.         MOV     AL,BL
  67.         SHR     AL,CL
  68.         CALL    PRHEX
  69.         MOV     AL,BL
  70.         CALL    PRHEX
  71.         lea     dx, CRLF
  72.         mov     ah, 9
  73.         int     021h
  74.  
  75.         LEA     DX,TIBTAZ
  76.         INT     027H
  77.  
  78. PRHEX:  AND     AL,00FH
  79.         ADD     AL,030H
  80.         CMP     AL,03AH
  81.         JB      PHG
  82.         ADD     AL,7
  83. PHG:    MOV     DL,AL
  84.         MOV     AH,2
  85.         INT     021H
  86.         RET
  87.  
  88. PGMNAME DB      "TIBTAZ - Trap (Int3) Branch To Absolute Zero!  PSP: $"
  89. CRLF    DB      13, 10, 36
  90.  
  91. CSEG    ENDS
  92.         END     TIBTAZ                  ;necessary for .COM files
  93.  
  94.  
  95.